package com.prj.dy.common
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	
	public class DYDispatcher extends EventDispatcher
	{
		
		// The Singleton instance.
		protected static var instance : DYDispatcher = null; 
		
		// Message Constants
		protected const SINGLETON_MSG	: String = "DYDispatcher Singleton already constructed!";		
		
		
		public function DYDispatcher(target:IEventDispatcher=null)
		{			
			super(target);
			
			if (instance != null) 
				throw Error(SINGLETON_MSG);	
		}
		
		
		public static function getInstance():DYDispatcher
		{
			if (instance == null) 
				instance = new DYDispatcher( );
			
			return instance;
		}
				
		
		public function dispatchEventFor(from:EventDispatcher, type:String, data:Object=null):void
		{
			this.dispatchEvent(new DYEvent(from, type, data)); 			
		}
	}
}